package com.loan.psychicloan.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.loan.psychicloan.R;
import com.ycl.tabview.library.TabView;
import com.ycl.tabview.library.TabViewChild;

import java.util.ArrayList;
import java.util.List;


public class FragmentSample extends Fragment {
    TabView tabView;
    @Nullable @Override
    public View onCreateView(LayoutInflater inflater,
                             @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_sample,container,false);
        tabView= view.findViewById(R.id.tabView);
        init();
        return view;
    }
    private void init(){
        //start add data
        List<TabViewChild> tabViewChildList=new ArrayList<>();
        TabViewChild tabViewChild01=new TabViewChild(R.mipmap.home_check,R.mipmap.home_unsel,"首页",  FragmentHome.newInstance());
        TabViewChild tabViewChild02=new TabViewChild(R.mipmap.loan_check,R.mipmap.loan_unsel,"贷款",  FragmentLoanPage.newInstance());
        TabViewChild tabViewChild03=new TabViewChild(R.mipmap.mine_check,R.mipmap.mine_unsel,"我的",  FragmentMine.newInstance());
        tabViewChildList.add(tabViewChild01);
        tabViewChildList.add(tabViewChild02);
        tabViewChildList.add(tabViewChild03);
        //end add data
        tabView.setTabViewDefaultPosition(0);
        tabView.setTextViewSelectedColor(Color.argb(255,45,155,235));
        tabView.setTabViewChild(tabViewChildList,getChildFragmentManager());
        tabView.setOnTabChildClickListener(new TabView.OnTabChildClickListener() {
            @Override
            public void onTabChildClick(int  position, ImageView currentImageIcon, TextView currentTextView) {
                // Toast.makeText(getApplicationContext(),"position:"+position,Toast.LENGTH_SHORT).show();
            }
        });
    }
}
